package com.lebang.service.setting;

import com.lebang.domain.PromotionRewardSetting;
import com.lebang.entity.member.LbbMember;
import com.lebang.entity.member.TbMemberInviteStatistics;
import com.lebang.example.PromotionRewardSettingExample;
import com.lebang.mapper.PromotionRewardSettingMapper;
import com.lebang.mapper.TbMemberInviteStatisticsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PromotionRewardService {
    @Autowired
    private PromotionRewardSettingMapper promotionRewardSettingMapper;
    @Autowired
    private TbMemberInviteStatisticsMapper tbMemberInviteStatisticsMapper;


    public PromotionRewardSetting checkReward(LbbMember lbbMember) {
        TbMemberInviteStatistics memberInviteStatistics = tbMemberInviteStatisticsMapper.getByMemberId(lbbMember.getMemberId());
        PromotionRewardSettingExample example=new PromotionRewardSettingExample();
        example.createCriteria().andHasDeletedEqualTo(0);
        List<PromotionRewardSetting> list = promotionRewardSettingMapper.selectByExample(example);
        for (PromotionRewardSetting next : list) {
            if (memberInviteStatistics.getNumbers().equals(next.getNumbers())) {
                //收徒人数达到对应人数时，可获对应奖励
                return next;

            }
        }
        return null;
    }
}



